<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>

<c:set var="ctx" value="${pageContext.request.contextPath}" />


<div id="home">
	<input type="hidden" value=<shiro:principal property="id"/> id="user_id"/>
	<div class="home-page">
		<div class="media container" id="userInfor">
			<div class="laoding-round"></div>
		</div>
		<div>
			<a href="#chart" data-toggle="modal" >
				<div class="chart_button" style="display:none;">发私信</div>
			</a>
		</div>
		<div class="media" id="renzheng">
			<c:choose>
				<c:when test="${user.roles == 'user'}">
				<button class="raise-submit" id="renzhengjigou" style="width:auto !important;"></button>
				<!-- <button class="raise-submit" id="renzhengzrj">认证投资人</button> -->
				</c:when>
			</c:choose>
		</div>
		<div id="chart" class="modal hide fade" role="dialog"
			aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-header" style="background-color: #ffcc00;color: #834313;font-size: 15px;font-weight: bold;">
				<button class="close" data-dismiss="modal" aria-hidden="true"></button>
				发私信给:<span class="send_to" id="send-name" style="margin-left: 10px;"></span>
			</div>
			<form style="height: auto;" action="" method="post" id="sendLeterTo">
				<input type="hidden" name="userId" value="" class="userId">
				<input type="hidden" name="friendId" value="" class="friendId">
				<input type="hidden" name="letterTo" value="" class="userId">
				<input type="hidden" name="letterFrom" value="" class="friendId">
				<div class="chart_inform">
					<textarea name="content"></textarea>
				</div>
				<div class="chart_submit">
					<label for="chartSubmit">发送</label><input id="chartSubmit"
						type="button" value="">
				</div>
			</form>
		</div>
		<div class="home-tab-border">
			<div class="container">
				<ul class="nav nav-tabs" id="home-tab">
					<li class="active" id="startedProject" style="display: none"><a
						href="#start-project"> <span class="hidden-phone">已发的服务</span><span class="visible-phone">已发</span></a></li>
					<li class="active hidden-phone" style="display: none;" id="recommenProject"><a
						href="#recommend-project"> <span>推荐的服务</span></a></li>
					<li id="supportProject"><a href="#support-project"><span class="hidden-phone">资助的服务</span><span class="visible-phone">资助</span></a></li>
					<li class="hidden-phone"><a href="#share-project"><span> 分享的服务</span></a></li>
					<li><a href="#attention-project"><span class="hidden-phone">关注的服务</span><span class="visible-phone">关注</span>	</a></li>
					<li><a href="#comment-project"><span class="hidden-phone">评论的服务</span><span class="visible-phone">评论</span>	</a></li>
				</ul>
			</div>
		</div>
		<div class="tab-wrap">
			<div class="tab-content container" style="background-color: #ffffff;">
			<!-- 发起的服务 -->
			<div class="tab-pane active" id="start-project"
				style="min-height: 500px; display: none">
					<div class="laoding-round"></div>
				</div>
			<!-- 推荐的服务 -->
			<div class="tab-pane active" id="recommend-project"
				style="min-height: 500px; display: none"></div>
			<!-- 资助的服务 -->
			<div class="tab-pane" id="support-project" style="min-height: 500px;"></div>
			<!--  分享的服务-->
			<div class="tab-pane" id="share-project" style="min-height: 500px;"></div>
			<!--  关注的服务-->
			<div class="tab-pane" id="attention-project"
				style="min-height: 500px;"></div>
			<!--  评论的服务-->
			<div class="tab-pane" id="comment-project" style="min-height: 500px;">

			</div>
			<div class="letter_send_seccuss">
				<span class="show_success"></span>发送成功
			</div>
		</div>
		</div>
		
	</div>
</div>

<!-- 发起的服务 -->
<script type="text/html" id="start-project-template">
<$ if ( result.length <= 0 ) { $>
			<span class="empty-center">亲，你还没有发起服务哦.</span>
		<$}else{$>
<table class="table table-hover">
	<thead>
	<tr>
		<th class="table_hover_name visi-tab-name">服务名称</th>
		<th class="textcenter table_hover_time visi-time-name">状态</th>
		<th class="table_hover_address hidden-phone">地点</th>
		<th class="textcenter table_hover_time">购买人数</th>
		<th class="textcenter table_hover_time hidden-phone">发起时间</th>
		<th class="textcenter table_hover_time">已售金额</th>
		<th class="textcenter table_hover_opt hidden-phone" >操作</th>
	</tr>
	<tbody>
	<$ if ( result.length <= 0 ) { $>
		<span>亲，你还没有发起服务哦.<a href="#">马上去发</a></span>
	<$}else{$>
	<$for(var i = 0;i<result.length;i++){$>
		<tr class="activty_tr">
			<td class="column1">
				<div class="media hidden-phone">
					<$if(result[i].status!=0){$>
						<a href="${ctx}/project/detail?id=<$=result[i].id$>" class="pull-left">
						<img class="media-object img-polaroid" alt="" src="<$=result[i].photoUrl$>"></a>
						<a href="${ctx}/project/detail?id=<$=result[i].id$>" class="color_theme media-align-middle"><$=result[i].name$></a>
					<$}else{$>
						<img class="pull-left media-object img-polaroid" alt="" src="<$=result[i].photoUrl$>">
						<span><$=result[i].name$></span>						
					<$}$>
				</div>
                <span class="visible-phone"><$=result[i].name$></span>
			</td>
							<td class="textcenter"><span>
					<$
						switch(result[i].status)
							{
								case 0:
 								print("草稿");
  								break;
								case 1:
 								print("预审");
  								break;

								case 5:
 								print("进行中");
  								break;
								case 6:
 								print("关闭");
  								break;
								default:
					}$></span></td>
			<td class="table_hover_address hidden-phone"><span><i class="address_icon"></i><$=result[i].cityRegion.name$></span></td>
			<td class="textcenter"><span><$=result[i].supportCount$>人</span></td>
			<td class="textcenter hidden-phone"><span><$=result[i].createdDate$></span></td>
			<td class="textcenter"><span><$=result[i].fundCurrent$>元</span></td>
			<$if(result[i].status == '0' || result[i].status == '1' ) {$>
				<td class="textcenter hidden-phone"><span><a href="${ctx}/project/edit?uid=<$=result[i].institution.user.id$>&pid=<$=result[i].id$>">修改</a></span></td>
			<$} else {$>
				<td class="textcenter hidden-phone"><span>修改</span></td>
			<$}$>
		</tr>
	<$}	$>
	<$}	$><$}$>
	</tbody>
</table>
<$ if ( totalPages > 1 ) { $>
	<div class="pagination">
		<$==pagination$>
	</div>	
<$ } $>		
</script>

<!-- 分享的服务 -->
<script type="text/html" id="share-project-template">
<$ if ( result.length <= 0 ) { $>
			<span class="empty-center">亲，你还没有分享服务哦.</span>
		<$}else{$>
<table class="table table-hover">
	<thead>
		<tr>
			<th class="table_hover_name">服务名称</th>
			<th class="table_hover_time textcenter">状态</th>
			<th class="table_hover_address hidden-phone">地点</th>
			<th class="table_hover_time textcenter hidden-phone">分享时间</th>
			<th class="table_hover_time textcenter">分享人数</th>
			<th class="table_hover_time textcenter">已获资助</th>
		</tr>
	</thead>
	<tbody>
		<$for(var i = 0;i<result.length;i++){$>
			<tr class="activty_tr">
				<td class="column1">
					<div class="media">
						<a href="${ctx}/project/detail?id=<$=result[i].project.id$>" class="pull-left hidden-phone"><img class="media-object img-polaroid" alt="" src="<$=result[i].project.photoUrl$>"></a> 
						<a href="${ctx}/project/detail?id=<$=result[i].project.id$>" class="color_theme media-align-middle"><$=result[i].project.name$></a>
					</div>
				</td>
				<td class="textcenter"><span>
					<$
						switch(result[i].project.status)
							{
								case 1:
 								print("预审");
  								break;

								case 3:
 								print("众筹");
  								break;
								case 4:
 								print("执行");
  								break;
								case 5:
 								print("进行中");
  								break;
								case 6:
 								print("失败");
  								break;
								default:
					}$></span></td>
				<td class="table_hover_address hidden-phone"><span><i class="address_icon"></i><$=result[i].project.cityRegion.name$></span></td>
				<td class="textcenter hidden-phone"><span><$=result[i].createdDate$></span></td>
				<td class="textcenter"><span><$=result[i].project.shareCount$>人</span></td>
				<td class="textcenter"><span><$=result[i].project.fundCurrent$>元</span></td>
			</tr>
		<$}$><$}$>
	</tbody>
</table>	
<$ if ( totalPages > 1 ) { $>
	<div class="pagination">
		<$==pagination$>
	</div>
<$ } $>
</script>
<!-- 资助的服务 -->
<script type="text/html" id="support-project-template">
<$ if ( result.length <= 0 ) { $>
			<span class="empty-center">亲，你还没有资助服务哦.</span>
		<$}else{$>
<table class="table table-hover">
	<thead>
		<tr>
			<th class="table_hover_name visi-hover-name" width="">服务名称</th>
			<th class="textcenter table_hover_time" style="min-width:60px;" width="">状态</th>
            <th class="textcenter hidden-phone" width="">类型</th>
			<th class="table_hover_address hidden-phone" width="15%">地点</th>
			<th class="textcentertable_hover_time" width="">资助金额</th>
			<th class="textcenter table_hover_time hidden-phone" width="">资助时间</th>
			<th class="textcenter table_hover_time" style="min-width:60px;">已获资助</th>
		</tr>
	</thead>
	<tbody>
		<$for(var i = 0;i<result.length;i++){$>
			<tr class="activty_tr">
				<td class="column1">
					<div class="media hidden-phone">
						<a href="${ctx}/project/detail?id=<$=result[i].project.id$>" class="pull-left hidden-phone"><img class="media-object img-polaroid" alt="80x80" title="<$=result[i].project.name$>" src="<$=result[i].project.photoUrl$>"></a> 
						<a href="${ctx}/project/detail?id=<$=result[i].project.id$>" class="color_theme media-align-middle" ><$=result[i].project.name$></a>
					</div>
                  <a href="${ctx}/project/detail?id=<$=result[i].project.id$>" class="color_theme media-align-middle visi-name visible-phone" ><$=result[i].project.name$></a>
				</td>
				<td class="textcenter" style="min-width:60px;"><span>
					<$
						switch(result[i].project.status)
							{
								case 1:
 								print("预审");
  								break;
								case 3:
 								print("众筹");
  								break;
								case 4:
 								print("执行");
  								break;
								case 5:
 								print("进行中");
  								break;
								case 6:
 								print("失败");
  								break;
								default:
					}$></span></td>
                <td class="textcenter hidden-phone"><span><$
						switch(result[i].isBuy)
							{
								case 1:
 								print("送礼");
  								break;
								case 0:
 								print("购买");
  								break;
                             default:
					}$></span></td>
				<td class="table_hover_address hidden-phone"><span><i class="address_icon"></i><$=result[i].project.cityRegion.name$></span></td>
				<td class="textcenter"><span><$=result[i].productAmount*result[i].productPrice$>元</span></td>
				<td class="textcenter hidden-phone"><span><$=result[i].createdDate$></span></td>
				<td class="textcenter" style="min-width:60px;"><span><$=result[i].project.fundCurrent$>元</td>
			</tr>
		<$}$><$}$>
	</tbody>
</table>
<$ if ( totalPages > 1 ) { $>
	<div class="pagination">
		<$==pagination$>
	</div>
<$ } $>										
</script>
<!-- 关注的服务 -->
<script type="text/html" id="attention-project-template">
<$ if ( result.length <= 0 ) { $>
			<span class="empty-center">亲，你还没有关注服务哦.</span>
		<$}else{$>
<table class="table table-hover">
	<thead>
		<tr>
			<th class="table_hover_name visi-width">服务名称</th>
			<th class="textcenter table_hover_time">状态</th>
			<th class="table_hover_address hidden-phone">地点</th>
			<th class="textcenter table_hover_time hidden-phone">关注时间</th>
			<th class="textcenter table_hover_time" style="min-widht:60px;">关注人数</th>
			<th class="textcenter table_hover_time">已获资助</th>
		</tr>
	</thead>
	<tbody id="follow-project-tbody">
		<$for(var i = 0;i<result.length;i++){$>
			<tr class="activty_tr">
				<td class="column1">
					<div class="media hidden-phone">
						<a href="${ctx}/project/detail?id=<$=result[i].project.id$>" class="pull-left hidden-phone"><img class="media-object img-polaroid" alt="" src="<$=result[i].project.photoUrl$>"></a> 
						<a href="${ctx}/project/detail?id=<$=result[i].project.id$>" class="color_theme media-align-middle"><$=result[i].project.name$></a>
					</div>
                <a href="${ctx}/project/detail?id=<$=result[i].project.id$>" class="color_theme media-align-middle visi-name visible-phone"><$=result[i].project.name$></a>
				</td>
				<td class="textcenter"><span>
					<$
						switch(result[i].project.status)
							{
								case 1:
 								print("预审");
  								break;

								case 3:
 								print("众筹");
  								break;
								case 4:
 								print("执行");
  								break;
								case 5:
 								print("进行中");
  								break;
								case 6:
 								print("失败");
  								break;
								default:
					}$></span></td>
				<td class="table_hover_address hidden-phone"><span><i class="address_icon"></i><$=result[i].project.cityRegion.name$></span></td>
				<td class="textcenter hidden-phone"><span><$=result[i].createdDate$></span></td>
				<td class="textcenter" style="min-widht:60px;"><span><$=result[i].project.attentionCount$>人</span></td>
				<td class="textcenter"><span><$=result[i].project.fundCurrent$>元</span></td>
			</tr>
		<$}$><$}$>
	</tbody>
</table>
<$ if ( totalPages > 1 ) { $>
	<div class="pagination">
		<$==pagination$>
	</div>
<$ } $>										
</script>
<!-- 评论的服务 -->
<script id="commend-project-template" type="text/html">
<$ if ( result.length <= 0 ) { $>
			<span class="empty-center">亲，你还没有评论服务哦.</span>
		<$}else{$>
<table class="table table-hover">
	<thead >
		<tr>
			<th class="table_hover_name comment_count" colspan="3">共 <i><$= result.length $></i> 条
		</tr>
	</thead>
	<tbody id="comment-project-tbody">
		<$for(var i = 0;i<result.length;i++){$>
			<$if(result[i].superId == null){$>
				<tr class="activty_tr" >
					<td  >
					<$if(result[i].projectId == null && result[i].preferentialId != null){$>
						<a href="${ctx}/project/preferential/detail?id=<$=result[i].preferentialId$>" class="pull-left hidden-phone"><img class="media-object img-polaroid" alt="" src="<$=result[i].preferentialImg$>"></a> 
						<strong style="line-height:30px;margin-left:10px;font-size: 16px;"><$=result[i].userContent$></strong><br/>
						<a style="line-height:30px;margin-left:6px;color:gray;" href="${ctx}/project/preferential/detail?id=<$=result[i].preferentialId$>">评论活动：<$=result[i].preferentialName$></a><br/>
						<span class="commment_creatdate" style="line-height:30px;margin-left:10px;display:block;color:gray;float:left;"><$= result[i].userCreatedDate $></span>
					<$}else if(result[i].projectId != null && result[i].preferentialId == null) {$>
						<a href="${ctx}/project/detail?id=<$=result[i].projectId$>" class="pull-left hidden-phone"><img class="media-object img-polaroid" alt="" src="<$=result[i].projectImg$>"></a> 
						<strong style="line-height:30px;margin-left:10px;font-size: 16px;"><$=result[i].userContent$></strong><br/>
						<a style="line-height:30px;margin-left:6px;color:gray;" href="${ctx}/project/detail?id=<$=result[i].projectId$>">评论服务：<$=result[i].projectName$></a><br/>
						<span class="commment_creatdate" style="line-height:30px;margin-left:10px;display:block;color:gray;float:left;"><$= result[i].userCreatedDate $></span>
					<$}$>
					</td>
				</tr>
			<$}$>	
		<$}$>	
	<$}$>
	</tbody>
</table>
<$ if ( totalPages > 1 ) { $>
	<div class="pagination">
		<$==pagination$>
	</div>
<$ } $>								
</script>
<!-- 用户信息-->
<script type="text/html" id="userInfor-template">
			<div class="chart_to hidden-phone">
				<a href="${ctx}/home/profile?id=<$=user.id$>" class="pull-right"><img
					src="<$=user.avatarUrl$>/180x180" class="media-object hidden-phone" style="height: 170px;width: 175px;" alt='175x170' title="<$=user.name$>"/></a>
			</div>
			<div class="media-body">
				<div id="div_info">
					<h5 class="media-heading"><span id="span_name"><$=user.name$></span></h5>
					<span ><i class="address "></i></span>
					<span class="" href="#"><$=user.address$></span>
				</div>
				<div class="loginna" data='<$=user.id$>'>
					登录名： <$=user.loginName$><span id="roles" style="margin-right:10px;"></span>
				</div>
				<div id="gyjsz">
					 账户余额： <$=user.fund$>
				</div>
				<div><!--test-->
			  入驻时间： <$=user.registDate$>
			  </div>
			  <div>
			  自我介绍： 
					<span class="intro"><$if(user.description){$> <$=user.description$> <$} else{$> 此处空空如也~~ <$}$>
				</span>
				</div>
			</div>
</script>


<script type="text/html" id="comment-project-thead-template">
						<tr>
							<th class="table_hover_name comment_count" colspan="6">共<i><$=result.length$></i>条
						</tr>
</script>

<c:if test="${env == 'production' }">
<script type="text/javascript">
	seajs.use("${ctx}/assets/js-dist/home/home-page");
</script>
</c:if>
<c:if test="${env != 'production' }">
<script type="text/javascript">
	seajs.use("${ctx}/assets/js/home/home-page");
</script>
</c:if>
